


class CarModels {
    constructor(ctx) {
        this.ctx = ctx
    }

    /**
     * 
     * @param {*} id 
     */
    DataTable(id = 0) {
        let model = this.db('jh_car_models as a')
            .leftJoin('jh_carscategory as b', 'b.id', 'a.carscategory_id')
            .leftJoin('jh_car_brand as c', 'c.id', 'a.brand_id')
            .select('a.*', 'b.name as carscategory', 'c.name as brand')
            .where('a.status', '>', 0);

        if (id) {
            model.where('a.id', id).first()
        }

        return model;
    }

}

export default CarModels